/**
 * @fileOverview base util
 * @author huangtonger@aliyun.com
 */

const Base = require('../../base/util/');

module.exports = {
  ...Base,
  /**
   * get parallel
   * @param  {object} source - g6 node
   * @param  {object} target - g6 node
   * @param  {boolean} reverse - if get reverse edge
   * @return {array} rect
   */
  getParallelEdges(source, target, reverse = false) {
    const edges = source.getEdges();
    return edges.filter(edge => {
      const model = edge.getModel();
      return model.target === target.id || (reverse && model.source === target.id);
    });
  },
  object2array(object) {
    const rst = [];
    Base.each(object, sub => {
      rst.push(sub);
    });
    return rst;
  }
};
